/*------------------------------------------------------------------------*/
/*  Copyright 2014 National Renewable Energy Laboratory.                  */
/*  This software is released under the license detailed                  */
/*  in the file, LICENSE, which is located in the top-level Nalu          */
/*  directory structure                                                   */
/*------------------------------------------------------------------------*/

#include "kernels/UnitTestKernelUtils.h"
#include "UnitTestUtils.h"
#include "UnitTestHelperObjects.h"

#include "nso/MomentumNSOElemKernel.h"

namespace  {
namespace hex8_golds {

namespace nso_2nd {
static constexpr double rhs[24] = {
  -0.0063707777161640, 0.0063707777161640,  0.0000000000000000,
  -0.0086081947887376, -0.0106799702967435, 0.0000000000000000,
  0.0042990022081580,  -0.0042990022081580, 0.0000000000000000,
  0.0106799702967435,  0.0086081947887376,  0.0000000000000000,
  -0.0063707777161640, 0.0063707777161640,  0.0000000000000000,
  -0.0086081947887376, -0.0106799702967436, 0.0000000000000000,
  0.0042990022081580,  -0.0042990022081580, 0.0000000000000000,
  0.0106799702967436,  0.0086081947887376,  0.0000000000000000,
};

static constexpr double lhs[24][24] = {
  { 0.0147668005079912, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000, 0.0000000000000000, -0.0033188031919072, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000, 0.0000000000000000, 0.0001118759037275, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000, 0.0000000000000000, -0.0016407556119990, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0147668005079912, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000, 0.0000000000000000, -0.0033188031919072, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000, 0.0000000000000000, 0.0001118759037275, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000, 0.0000000000000000, -0.0016407556119990, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, 0.0000000009269929, 0.0000000000000000, 0.0000000000000000, -0.0000000002764716, 0.0000000000000000, 0.0000000000000000, -0.0000000001788934, 0.0000000000000000, 0.0000000000000000, 0.0000000000487891, 0.0000000000000000, 0.0000000000000000, -0.0000000000813152, 0.0000000000000000, 0.0000000000000000, -0.0000000002222614, 0.0000000000000000, 0.0000000000000000, -0.0000000001029992, 0.0000000000000000, 0.0000000000000000, -0.0000000001138412,  },
  { -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000, 0.0000000000000000, -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000, 0.0000000000000000, -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, -0.0000000003496552, 0.0000000000000000, 0.0000000000000000, 0.0000000007074419, 0.0000000000000000, 0.0000000000000000, -0.0000000000894467, 0.0000000000000000, 0.0000000000000000, -0.0000000002249720, 0.0000000000000000, 0.0000000000000000, -0.0000000001273938, 0.0000000000000000, 0.0000000000000000, 0.0000000002032879, 0.0000000000000000, 0.0000000000000000, -0.0000000000406576, 0.0000000000000000, 0.0000000000000000, -0.0000000000786047,  },
  { -0.0042946317261608, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000, 0.0000000000000000, 0.0239989596604141, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000, 0.0000000000000000, -0.0026665510733793, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000, 0.0000000000000000, -0.0031154112617937, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, -0.0042946317261608, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000, 0.0000000000000000, 0.0239989596604141, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000, 0.0000000000000000, -0.0026665510733793, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000, 0.0000000000000000, -0.0031154112617937, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, -0.0000000001355253, 0.0000000000000000, 0.0000000000000000, -0.0000000001463673, 0.0000000000000000, 0.0000000000000000, 0.0000000005366801, 0.0000000000000000, 0.0000000000000000, -0.0000000000813152, 0.0000000000000000, 0.0000000000000000, -0.0000000000596311, 0.0000000000000000, 0.0000000000000000, -0.0000000000921572, 0.0000000000000000, 0.0000000000000000, 0.0000000000487891, 0.0000000000000000, 0.0000000000000000, -0.0000000000704731,  },
  { -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000, 0.0000000000000000, -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000, 0.0000000000000000, -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, -0.0000000001301043, 0.0000000000000000, 0.0000000000000000, -0.0000000001301043, 0.0000000000000000, 0.0000000000000000, -0.0000000001301043, 0.0000000000000000, 0.0000000000000000, 0.0000000003903128, 0.0000000000000000, 0.0000000000000000, -0.0000000000433681, 0.0000000000000000, 0.0000000000000000, -0.0000000000433681, 0.0000000000000000, 0.0000000000000000, -0.0000000000433681, 0.0000000000000000, 0.0000000000000000, 0.0000000001301043,  },
  { 0.0001118759037275, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000, 0.0000000000000000, -0.0016407556119990, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000, 0.0000000000000000, 0.0147668005079912, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000, 0.0000000000000000, -0.0033188031919072, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0001118759037275, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000, 0.0000000000000000, -0.0016407556119990, 0.0000000000000000, 0.0000000000000000, -0.0024424874340440, 0.0000000000000000, 0.0000000000000000, 0.0147668005079912, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000, 0.0000000000000000, -0.0033188031919072, 0.0000000000000000, 0.0000000000000000, -0.0025170713698623, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, -0.0000000000813152, 0.0000000000000000, 0.0000000000000000, -0.0000000002222614, 0.0000000000000000, 0.0000000000000000, -0.0000000001029992, 0.0000000000000000, 0.0000000000000000, -0.0000000001138412, 0.0000000000000000, 0.0000000000000000, 0.0000000009269929, 0.0000000000000000, 0.0000000000000000, -0.0000000002764716, 0.0000000000000000, 0.0000000000000000, -0.0000000001788934, 0.0000000000000000, 0.0000000000000000, 0.0000000000487891,  },
  { -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000, 0.0000000000000000, -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000, 0.0000000000000000, -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, -0.0000000001273938, 0.0000000000000000, 0.0000000000000000, 0.0000000002032879, 0.0000000000000000, 0.0000000000000000, -0.0000000000406576, 0.0000000000000000, 0.0000000000000000, -0.0000000000786047, 0.0000000000000000, 0.0000000000000000, -0.0000000003496552, 0.0000000000000000, 0.0000000000000000, 0.0000000007074419, 0.0000000000000000, 0.0000000000000000, -0.0000000000894467, 0.0000000000000000, 0.0000000000000000, -0.0000000002249720,  },
  { -0.0026665510733793, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000, 0.0000000000000000, -0.0031154112617937, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000, 0.0000000000000000, -0.0042946317261608, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000, 0.0000000000000000, 0.0239989596604141, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, -0.0026665510733793, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000, 0.0000000000000000, -0.0031154112617937, 0.0000000000000000, 0.0000000000000000, -0.0045190618203680, 0.0000000000000000, 0.0000000000000000, -0.0042946317261608, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000, 0.0000000000000000, 0.0239989596604141, 0.0000000000000000, 0.0000000000000000, -0.0024421209791722, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, -0.0000000000596311, 0.0000000000000000, 0.0000000000000000, -0.0000000000921572, 0.0000000000000000, 0.0000000000000000, 0.0000000000487891, 0.0000000000000000, 0.0000000000000000, -0.0000000000704731, 0.0000000000000000, 0.0000000000000000, -0.0000000001355253, 0.0000000000000000, 0.0000000000000000, -0.0000000001463673, 0.0000000000000000, 0.0000000000000000, 0.0000000005366801, 0.0000000000000000, 0.0000000000000000, -0.0000000000813152,  },
  { -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000, 0.0000000000000000, -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000, 0.0000000000000000,  },
  { 0.0000000000000000, -0.0036235166870317, 0.0000000000000000, 0.0000000000000000, -0.0023680360289339, 0.0000000000000000, 0.0000000000000000, -0.0046243286848487, 0.0000000000000000, 0.0000000000000000, -0.0034312118552358, 0.0000000000000000, 0.0000000000000000, -0.0003352301190575, 0.0000000000000000, 0.0000000000000000, -0.0035923347727893, 0.0000000000000000, 0.0000000000000000, -0.0033376661125084, 0.0000000000000000, 0.0000000000000000, 0.0213123242604053, 0.0000000000000000,  },
  { 0.0000000000000000, 0.0000000000000000, -0.0000000000433681, 0.0000000000000000, 0.0000000000000000, -0.0000000000433681, 0.0000000000000000, 0.0000000000000000, -0.0000000000433681, 0.0000000000000000, 0.0000000000000000, 0.0000000001301043, 0.0000000000000000, 0.0000000000000000, -0.0000000001301043, 0.0000000000000000, 0.0000000000000000, -0.0000000001301043, 0.0000000000000000, 0.0000000000000000, -0.0000000001301043, 0.0000000000000000, 0.0000000000000000, 0.0000000003903128,  },
};

}

namespace nso_2nd_alt {
static constexpr double rhs[24] = {
  -0.0067835094599859, 0.0067835094599859,  0.0000000000000000,
  -0.0081954630449157, -0.0106799702967435, 0.0000000000000000,
  0.0042990022081580,  -0.0042990022081580, 0.0000000000000000,
  0.0106799702967435,  0.0081954630449157,  0.0000000000000000,
  -0.0067835094599859, 0.0067835094599859,  0.0000000000000000,
  -0.0081954630449157, -0.0106799702967436, 0.0000000000000000,
  0.0042990022081580,  -0.0042990022081580, 0.0000000000000000,
  0.0106799702967436,  0.0081954630449157,  0.0000000000000000,
};

static constexpr double lhs[24][24] = {
  {
    0.0116208224874254,  0.0000000000000000, 0.0000000000000000,
    0.0001471240192361,  0.0000000000000000, 0.0000000000000000,
    -0.0024307380622077, 0.0000000000000000, 0.0000000000000000,
    -0.0035657307100509, 0.0000000000000000, 0.0000000000000000,
    -0.0004550008049937, 0.0000000000000000, 0.0000000000000000,
    -0.0013938280938554, 0.0000000000000000, 0.0000000000000000,
    -0.0012912024986028, 0.0000000000000000, 0.0000000000000000,
    -0.0026314463369510, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0116208224874254,  0.0000000000000000,
    0.0000000000000000, -0.0035657307100509, 0.0000000000000000,
    0.0000000000000000, -0.0024307380622077, 0.0000000000000000,
    0.0000000000000000, 0.0001471240192361,  0.0000000000000000,
    0.0000000000000000, -0.0004550008049937, 0.0000000000000000,
    0.0000000000000000, -0.0026314463369510, 0.0000000000000000,
    0.0000000000000000, -0.0012912024986028, 0.0000000000000000,
    0.0000000000000000, -0.0013938280938553, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0011289237902231,  0.0000000000000000, 0.0000000000000000,
    0.0145662218003862,  0.0000000000000000, 0.0000000000000000,
    -0.0055863669325148, 0.0000000000000000, 0.0000000000000000,
    -0.0031042834696957, 0.0000000000000000, 0.0000000000000000,
    -0.0013748158670253, 0.0000000000000000, 0.0000000000000000,
    -0.0003979641245036, 0.0000000000000000, 0.0000000000000000,
    -0.0036132461079380, 0.0000000000000000, 0.0000000000000000,
    -0.0016184690889318, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, -0.0003352301190575, 0.0000000000000000,
    0.0000000000000000, 0.0213123242604053,  0.0000000000000000,
    0.0000000000000000, -0.0033376661125084, 0.0000000000000000,
    0.0000000000000000, -0.0035923347727893, 0.0000000000000000,
    0.0000000000000000, -0.0036235166870317, 0.0000000000000000,
    0.0000000000000000, -0.0034312118552358, 0.0000000000000000,
    0.0000000000000000, -0.0046243286848487, 0.0000000000000000,
    0.0000000000000000, -0.0023680360289339, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
  {
    -0.0042946317261608, 0.0000000000000000, 0.0000000000000000,
    -0.0024421209791722, 0.0000000000000000, 0.0000000000000000,
    0.0239989596604141,  0.0000000000000000, 0.0000000000000000,
    -0.0024421209791722, 0.0000000000000000, 0.0000000000000000,
    -0.0026665510733793, 0.0000000000000000, 0.0000000000000000,
    -0.0045190618203680, 0.0000000000000000, 0.0000000000000000,
    -0.0031154112617937, 0.0000000000000000, 0.0000000000000000,
    -0.0045190618203680, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, -0.0042946317261608, 0.0000000000000000,
    0.0000000000000000, -0.0024421209791722, 0.0000000000000000,
    0.0000000000000000, 0.0239989596604141,  0.0000000000000000,
    0.0000000000000000, -0.0024421209791722, 0.0000000000000000,
    0.0000000000000000, -0.0026665510733793, 0.0000000000000000,
    0.0000000000000000, -0.0045190618203680, 0.0000000000000000,
    0.0000000000000000, -0.0031154112617937, 0.0000000000000000,
    0.0000000000000000, -0.0045190618203680, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
  {
    -0.0003352301190575, 0.0000000000000000, 0.0000000000000000,
    -0.0035923347727893, 0.0000000000000000, 0.0000000000000000,
    -0.0033376661125084, 0.0000000000000000, 0.0000000000000000,
    0.0213123242604053,  0.0000000000000000, 0.0000000000000000,
    -0.0036235166870317, 0.0000000000000000, 0.0000000000000000,
    -0.0023680360289339, 0.0000000000000000, 0.0000000000000000,
    -0.0046243286848487, 0.0000000000000000, 0.0000000000000000,
    -0.0034312118552358, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0011289237902231,  0.0000000000000000,
    0.0000000000000000, -0.0031042834696957, 0.0000000000000000,
    0.0000000000000000, -0.0055863669325148, 0.0000000000000000,
    0.0000000000000000, 0.0145662218003862,  0.0000000000000000,
    0.0000000000000000, -0.0013748158670253, 0.0000000000000000,
    0.0000000000000000, -0.0016184690889318, 0.0000000000000000,
    0.0000000000000000, -0.0036132461079380, 0.0000000000000000,
    0.0000000000000000, -0.0003979641245037, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
  {
    -0.0004550008049937, 0.0000000000000000, 0.0000000000000000,
    -0.0013938280938554, 0.0000000000000000, 0.0000000000000000,
    -0.0012912024986028, 0.0000000000000000, 0.0000000000000000,
    -0.0026314463369510, 0.0000000000000000, 0.0000000000000000,
    0.0116208224874254,  0.0000000000000000, 0.0000000000000000,
    0.0001471240192361,  0.0000000000000000, 0.0000000000000000,
    -0.0024307380622077, 0.0000000000000000, 0.0000000000000000,
    -0.0035657307100509, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, -0.0004550008049937, 0.0000000000000000,
    0.0000000000000000, -0.0026314463369510, 0.0000000000000000,
    0.0000000000000000, -0.0012912024986028, 0.0000000000000000,
    0.0000000000000000, -0.0013938280938554, 0.0000000000000000,
    0.0000000000000000, 0.0116208224874254,  0.0000000000000000,
    0.0000000000000000, -0.0035657307100509, 0.0000000000000000,
    0.0000000000000000, -0.0024307380622077, 0.0000000000000000,
    0.0000000000000000, 0.0001471240192361,  0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
  {
    -0.0013748158670253, 0.0000000000000000, 0.0000000000000000,
    -0.0003979641245036, 0.0000000000000000, 0.0000000000000000,
    -0.0036132461079380, 0.0000000000000000, 0.0000000000000000,
    -0.0016184690889318, 0.0000000000000000, 0.0000000000000000,
    0.0011289237902231,  0.0000000000000000, 0.0000000000000000,
    0.0145662218003862,  0.0000000000000000, 0.0000000000000000,
    -0.0055863669325148, 0.0000000000000000, 0.0000000000000000,
    -0.0031042834696957, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, -0.0036235166870317, 0.0000000000000000,
    0.0000000000000000, -0.0034312118552358, 0.0000000000000000,
    0.0000000000000000, -0.0046243286848487, 0.0000000000000000,
    0.0000000000000000, -0.0023680360289339, 0.0000000000000000,
    0.0000000000000000, -0.0003352301190575, 0.0000000000000000,
    0.0000000000000000, 0.0213123242604053,  0.0000000000000000,
    0.0000000000000000, -0.0033376661125084, 0.0000000000000000,
    0.0000000000000000, -0.0035923347727893, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
  {
    -0.0026665510733793, 0.0000000000000000, 0.0000000000000000,
    -0.0045190618203680, 0.0000000000000000, 0.0000000000000000,
    -0.0031154112617937, 0.0000000000000000, 0.0000000000000000,
    -0.0045190618203680, 0.0000000000000000, 0.0000000000000000,
    -0.0042946317261608, 0.0000000000000000, 0.0000000000000000,
    -0.0024421209791722, 0.0000000000000000, 0.0000000000000000,
    0.0239989596604141,  0.0000000000000000, 0.0000000000000000,
    -0.0024421209791722, 0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, -0.0026665510733793, 0.0000000000000000,
    0.0000000000000000, -0.0045190618203680, 0.0000000000000000,
    0.0000000000000000, -0.0031154112617937, 0.0000000000000000,
    0.0000000000000000, -0.0045190618203680, 0.0000000000000000,
    0.0000000000000000, -0.0042946317261608, 0.0000000000000000,
    0.0000000000000000, -0.0024421209791722, 0.0000000000000000,
    0.0000000000000000, 0.0239989596604141,  0.0000000000000000,
    0.0000000000000000, -0.0024421209791722, 0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
  {
    -0.0036235166870317, 0.0000000000000000, 0.0000000000000000,
    -0.0023680360289339, 0.0000000000000000, 0.0000000000000000,
    -0.0046243286848487, 0.0000000000000000, 0.0000000000000000,
    -0.0034312118552358, 0.0000000000000000, 0.0000000000000000,
    -0.0003352301190575, 0.0000000000000000, 0.0000000000000000,
    -0.0035923347727893, 0.0000000000000000, 0.0000000000000000,
    -0.0033376661125084, 0.0000000000000000, 0.0000000000000000,
    0.0213123242604053,  0.0000000000000000, 0.0000000000000000,
  },
  {
    0.0000000000000000, -0.0013748158670253, 0.0000000000000000,
    0.0000000000000000, -0.0016184690889318, 0.0000000000000000,
    0.0000000000000000, -0.0036132461079380, 0.0000000000000000,
    0.0000000000000000, -0.0003979641245036, 0.0000000000000000,
    0.0000000000000000, 0.0011289237902231,  0.0000000000000000,
    0.0000000000000000, -0.0031042834696957, 0.0000000000000000,
    0.0000000000000000, -0.0055863669325148, 0.0000000000000000,
    0.0000000000000000, 0.0145662218003862,  0.0000000000000000,
  },
  {
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
    0.0000000000000000, 0.0000000000000000, 0.0000000000000000,
  },
};

} // nso_2nd

} // hex8_golds
} // anonymous namespace

TEST_F(MomentumKernelHex8Mesh, nso_2nd)
{
  fill_mesh_and_init_fields();

  // Setup solution options for default advection kernel
  solnOpts_.meshMotion_ = false;
  solnOpts_.meshDeformation_ = false;
  solnOpts_.externalMeshDeformation_ = false;
  solnOpts_.includeDivU_ = 0.0;

  unit_test_utils::HelperObjects helperObjs(bulk_, stk::topology::HEX_8, 3, partVec_[0]);

  // Initialize the kernel
  std::unique_ptr<sierra::nalu::Kernel> kernel(
    new sierra::nalu::MomentumNSOElemKernel<sierra::nalu::AlgTraitsHex8>(
      bulk_, solnOpts_, velocity_, dudx_, viscosity_, 0.0, 0.0,
      helperObjs.assembleElemSolverAlg->dataNeededByKernels_));

  // Add to kernels to be tested
  helperObjs.assembleElemSolverAlg->activeKernels_.push_back(kernel.get());

  // Mass terms need time integration information
  sierra::nalu::TimeIntegrator timeIntegrator;
  timeIntegrator.timeStepN_ = 0.1;
  timeIntegrator.timeStepNm1_ = 0.1;
  timeIntegrator.gamma1_ = 1.0;
  timeIntegrator.gamma2_ = -1.0;
  timeIntegrator.gamma3_ = 0.0;

  helperObjs.realm.timeIntegrator_ = &timeIntegrator;

  // Populate LHS and RHS
  helperObjs.assembleElemSolverAlg->execute();

  EXPECT_EQ(helperObjs.linsys->lhs_.extent(0), 24u);
  EXPECT_EQ(helperObjs.linsys->lhs_.extent(1), 24u);
  EXPECT_EQ(helperObjs.linsys->rhs_.extent(0), 24u);

  namespace gold_values = ::hex8_golds::nso_2nd;
  unit_test_kernel_utils::expect_all_near(helperObjs.linsys->rhs_,gold_values::rhs);
  unit_test_kernel_utils::expect_all_near<24>(helperObjs.linsys->lhs_, gold_values::lhs);
}

TEST_F(MomentumKernelHex8Mesh, nso_2nd_alt)
{
  fill_mesh_and_init_fields();

  // Setup solution options for default advection kernel
  solnOpts_.meshMotion_ = false;
  solnOpts_.meshDeformation_ = false;
  solnOpts_.externalMeshDeformation_ = false;
  solnOpts_.includeDivU_ = 0.0;

  unit_test_utils::HelperObjects helperObjs(bulk_, stk::topology::HEX_8, 3, partVec_[0]);

  // Initialize the kernel
  std::unique_ptr<sierra::nalu::Kernel> kernel(
    new sierra::nalu::MomentumNSOElemKernel<sierra::nalu::AlgTraitsHex8>(
      bulk_, solnOpts_, velocity_, dudx_, viscosity_, 0.0, 1.0,
      helperObjs.assembleElemSolverAlg->dataNeededByKernels_));

  // Add to kernels to be tested
  helperObjs.assembleElemSolverAlg->activeKernels_.push_back(kernel.get());

  // Mass terms need time integration information
  sierra::nalu::TimeIntegrator timeIntegrator;
  timeIntegrator.timeStepN_ = 0.1;
  timeIntegrator.timeStepNm1_ = 0.1;
  timeIntegrator.gamma1_ = 1.0;
  timeIntegrator.gamma2_ = -1.0;
  timeIntegrator.gamma3_ = 0.0;

  // Call Kernel setup with the time integrator to setup Kernel values
  kernel->setup(timeIntegrator);
  helperObjs.realm.timeIntegrator_ = &timeIntegrator;

  // Populate LHS and RHS
  helperObjs.assembleElemSolverAlg->execute();

  EXPECT_EQ(helperObjs.linsys->lhs_.extent(0), 24u);
  EXPECT_EQ(helperObjs.linsys->lhs_.extent(1), 24u);
  EXPECT_EQ(helperObjs.linsys->rhs_.extent(0), 24u);

  namespace gold_values = ::hex8_golds::nso_2nd_alt;
  unit_test_kernel_utils::expect_all_near(helperObjs.linsys->rhs_,gold_values::rhs);
  unit_test_kernel_utils::expect_all_near<24>(helperObjs.linsys->lhs_, gold_values::lhs);
}

